import excel "C:\Database.xlsx", sheet("Database") firstrow

rename ycus gdp
drop if year>=2020
encode country, gen (country1)
drop country
ren country1 country
xtset country year
gen trend = year - 1989
rename pubcap pubcap_percent
rename privcap privcap_percent
gen privk = (privcap_percent*gdp)/100
gen pubk = (pubcap_percent*gdp)/100
gen totk = privk + pubk
gen co2totk = (co2*1000000000)/totk
gen co2privk = (co2*1000000000)/privk
gen co2pubk = (co2*1000000000)/pubk
gen fossil = coal_cons + oil_cons + gas_cons
gen renew  = ren_cons + biofuels_cons + hydro_cons
gen renfos = (renew / fossil) 
gen struck = (privcap/pubcap)
gen efppc = efp / pop
gen laborpc = labor / pop
gen ylabor = gdp / labor
* logs
gen lnefppc = ln(efppc)
gen lnlaborpc = ln(laborpc)
gen lnylabor = ln(ylabor)
gen lnglob = ln(glob)
gen lnurb = ln(urb)
gen lntrd = ln(trd)
gen lnco2totk = ln(co2totk)
gen lnco2privk = ln(co2privk)
gen lnco2pubk = ln(co2pubk)
gen lnrenfos = ln(1+renfos)
* first differences
gen dco2totk = d.co2totk
gen dco2privk = d.co2privk
gen dco2pubk = d.co2pubk
gen drenfos = d.renfos
gen dstruck = d.struck
gen dinterestst = d.interestst
gen dinterestlt = d.interestlt
gen dtrd = d.trd
gen dglob = d.glob
gen durb = d.urb
gen defp = d.efp
gen defppc = d.efppc
gen dlnefppc = d.lnefppc
gen dlaborpc = d.laborpc
gen dlnlaborpc = d.lnlaborpc
gen dlfem = d.lfem
gen dratiofm = d.ratiofm
gen dylabor = d.ylabor
gen dlnylabor = d.lnylabor
gen dlnglob = d.lnglob
gen dlnurb = d.lnurb
gen dlntrd = d.lntrd
gen dlnco2totk = d.lnco2totk
gen dlnco2privk = d.lnco2privk
gen dlnco2pubk = d.lnco2pubk
gen dlnrenfos = d.lnrenfos
* lagged variables
gen l_co2totk   = l.co2totk
gen l_co2privk   = l.co2privk
gen l_co2pubk   = l.co2pubk
gen l_renfos = l.renfos
gen l_struck = l.struck
gen l_interestst = l.interestst
gen l_interestlt = l.interestlt
gen l_trd = l.trd
gen l_glob = l.glob
gen l_urb = l.urb
gen l_efp = l.efp
gen l_efppc = l.efppc
gen l_lnefppc = l.lnefppc
gen l_laborpc = l.laborpc
gen l_lnlaborpc = l.lnlaborpc
gen l_lfem = l.lfem
gen l_ratiofm = l.ratiofm
gen l_ylabor = l.ylabor
gen l_lnylabor = l.lnylabor
gen l_lnglob = l.lnglob
gen l_lnurb = l.lnurb
gen l_lntrd = l.lntrd
gen l_lnco2totk = l.lnco2totk
gen l_lnco2privk = l.lnco2privk
gen l_lnco2pubk = l.lnco2pubk
gen l_lnrenfos = l.lnrenfos
*
*** Article TABLES

* Table 2. Descriptive staistics of raw data
sum co2 fossil gdp privk pubk renew trd glob efp urb labor pop

* Table 3 Estimated models
* Model I
xtpmg dlnco2totk dlnrenfos dlnglob dlntrd dlnefp dlnurb dlnylabor, lr(l_lnco2totk l_lnrenfos l_lnglob l_lntrd l_lnefp l_lnurb l_lnylabor) ec(ecm) replace mg
estimates store mg
xtpmg dlnco2totk dlnrenfos dlnglob dlntrd dlnefp dlnurb dlnylabor, lr(l_lnco2totk l_lnrenfos l_lnglob l_lntrd l_lnefp l_lnurb l_lnylabor) ec(ecm) replace pmg
estimates store pmg
xtpmg dlnco2totk dlnrenfos dlnglob dlntrd dlnefp dlnurb dlnylabor, lr(l_lnco2totk l_lnrenfos l_lnglob l_lntrd l_lnefp l_lnurb l_lnylabor) ec(ecm) replace dfe
estimates store dfe
hausman mg pmg 
hausman mg pmg,sigmamore
hausman mg pmg,sigmaless
hausman pmg dfe 
hausman pmg dfe,sigmamore
hausman pmg dfe,sigmaless
hausman mg dfe 
hausman mg dfe,sigmamore
hausman mg dfe,sigmaless
* Model II
xtpmg dlnco2privk dlnrenfos dlnglob dlntrd dlnefp dlnurb dlnylabor, lr(l_lnco2privk l_lnrenfos l_lnglob l_lntrd l_lnefp l_lnurb l_lnylabor) ec(ecm) replace mg
estimates store mg
xtpmg dlnco2privk dlnrenfos dlnglob dlntrd dlnefp dlnurb dlnylabor, lr(l_lnco2privk l_lnrenfos l_lnglob l_lntrd l_lnefp l_lnurb l_lnylabor) ec(ecm) replace pmg
estimates store pmg
xtpmg dlnco2privk dlnrenfos dlnglob dlntrd dlnefp dlnurb dlnylabor, lr(l_lnco2privk l_lnrenfos l_lnglob l_lntrd l_lnefp l_lnurb l_lnylabor) ec(ecm) replace dfe
estimates store dfe
hausman mg pmg 
hausman mg pmg,sigmamore
hausman mg pmg,sigmaless
hausman pmg dfe 
hausman pmg dfe,sigmamore
hausman pmg dfe,sigmaless
hausman mg dfe 
hausman mg dfe,sigmamore
hausman mg dfe,sigmaless
* Model III
xtpmg dlnco2pubk dlnrenfos dlnglob dlntrd dlnefp dlnurb dlnylabor, lr(l_lnco2pubk l_lnrenfos l_lnglob l_lntrd l_lnefp l_lnurb l_lnylabor) ec(ecm) replace mg
estimates store mg
xtpmg dlnco2pubk dlnrenfos dlnglob dlntrd dlnefp dlnurb dlnylabor, lr(l_lnco2pubk l_lnrenfos l_lnglob l_lntrd l_lnefp l_lnurb l_lnylabor) ec(ecm) replace pmg
estimates store pmg
xtpmg dlnco2pubk dlnrenfos dlnglob dlntrd dlnefp dlnurb dlnylabor, lr(l_lnco2pubk l_lnrenfos l_lnglob l_lntrd l_lnefp l_lnurb l_lnylabor) ec(ecm) replace dfe
estimates store dfe
hausman mg pmg 
hausman mg pmg,sigmamore
hausman mg pmg,sigmaless
hausman pmg dfe 
hausman pmg dfe,sigmamore
hausman pmg dfe,sigmaless
hausman mg dfe 
hausman mg dfe,sigmamore
hausman mg dfe,sigmaless

* Table A1 Cross-sectional independence
xtcd lnco2totk lnco2privk lnco2pubk lnrenfos lnglob lntrd 
xtcd lnefp lnurb lnylabor
xtcd dlnco2totk dlnco2privk dlnco2pubk dlnrenfos dlnglob dlntrd
xtcd dlnefp dlnurb dlnylabor

* Table A2  Pesaran (2007) panel unit root test (CIPS)
multipurt lnco2totk lnco2privk lnco2pubk lnrenfos lnglob lntrd, lags(3)
multipurt lnefp lnurb lnylabor, lags(3)
multipurt dlnco2totk dlnco2privk dlnco2pubk dlnrenfos dlnglob dlntrd, lags(3)
multipurt dlnefp dlnurb dlnylabor, lags(3)

* Table A3 Multicollinearity tests
qui: reg lnco2totk lnrenfos lnglob lntrd lnefp lnurb lnylabor
estat vif
qui: reg dlnco2totk dlnrenfos dlnglob dlntrd dlnefp dlnurb dlnylabor
estat vif

* Table A4 Correlation matrix
pwcorr lnco2totk lnco2privk lnco2pubk lnrenfos lnglob lntrd lnefp lnurb lnylabor
pwcorr dlnco2totk dlnco2privk dlnco2pubk dlnrenfos dlnglob dlntrd dlnefp dlnurb dlnylabor

* Table A5 Diagnostic tests
* Slope heterogeneity tests (Pesaran and Yamagata, 2008) 
* Model I
xthst dlnco2totk dlnrenfos dlnglob dlntrd dlnefp dlnurb dlnylabor l_lnco2totk l_lnrenfos l_lnglob l_lntrd l_lnefp l_lnurb l_lnylabor 
* Model II
xthst dlnco2privk dlnrenfos dlnglob dlntrd dlnefp dlnurb dlnylabor l_lnco2totk l_lnrenfos l_lnglob l_lntrd l_lnefp l_lnurb l_lnylabor 
* Model III
xthst dlnco2pubk dlnrenfos dlnglob dlntrd dlnefp dlnurb dlnylabor l_lnco2totk l_lnrenfos l_lnglob l_lntrd l_lnefp l_lnurb l_lnylabor
* Heterocedasticity test 
* Model I
qui: xtreg dlnco2totk dlnrenfos dlnglob dlntrd dlnefp dlnurb dlnylabor l_lnco2totk l_lnrenfos l_lnglob l_lntrd l_lnefp l_lnurb l_lnylabor, fe
xttest3
* Model II
qui: xtreg dlnco2privk dlnrenfos dlnglob dlntrd dlnefp dlnurb dlnylabor l_lnco2totk l_lnrenfos l_lnglob l_lntrd l_lnefp l_lnurb l_lnylabor, fe
xttest3
* Model III
qui: xtreg dlnco2pubk dlnrenfos dlnglob dlntrd dlnefp dlnurb dlnylabor l_lnco2totk l_lnrenfos l_lnglob l_lntrd l_lnefp l_lnurb l_lnylabor, fe
xttest3
* Contemporaneous correlation test (cross-sectional independence test)
* Pesaran Friedman Frees
* Model I
qui: xtreg dlnco2totk dlnrenfos dlnglob dlntrd dlnefp dlnurb dlnylabor l_lnco2totk l_lnrenfos l_lnglob l_lntrd l_lnefp l_lnurb l_lnylabor, fe
xtcsd, pesaran abs 
xtcsd, friedman
xtcsd, frees
* Model II
qui: xtreg dlnco2privk dlnrenfos dlnglob dlntrd dlnefp dlnurb dlnylabor l_lnco2totk l_lnrenfos l_lnglob l_lntrd l_lnefp l_lnurb l_lnylabor, fe
xtcsd, pesaran abs 
xtcsd, friedman
xtcsd, frees
* Model III
qui: xtreg dlnco2pubk dlnrenfos dlnglob dlntrd dlnefp dlnurb dlnylabor l_lnco2totk l_lnrenfos l_lnglob l_lntrd l_lnefp l_lnurb l_lnylabor, fe
xtcsd, pesaran abs 
xtcsd, friedman
xtcsd, frees
* Breusch-Pagan LM
* Model I
qui: xtreg dlnco2totk dlnrenfos dlnglob dlntrd dlnefp dlnurb dlnylabor l_lnco2totk l_lnrenfos l_lnglob l_lntrd l_lnefp l_lnurb l_lnylabor, fe
xttest2
* Model II
qui: xtreg dlnco2privk dlnrenfos dlnglob dlntrd dlnefp dlnurb dlnylabor l_lnco2totk l_lnrenfos l_lnglob l_lntrd l_lnefp l_lnurb l_lnylabor, fe
xttest2
* Model III
qui: xtreg dlnco2pubk dlnrenfos dlnglob dlntrd dlnefp dlnurb dlnylabor l_lnco2totk l_lnrenfos l_lnglob l_lntrd l_lnefp l_lnurb l_lnylabor, fe
xttest2
* Autocorrelation test
* Model I
xtserial dlnco2totk dlnrenfos dlnglob dlntrd dlnefp dlnurb dlnylabor l_lnco2totk l_lnrenfos l_lnglob l_lntrd l_lnefp l_lnurb l_lnylabor
* Model II
xtserial dlnco2privk dlnrenfos dlnglob dlntrd dlnefp dlnurb dlnylabor l_lnco2totk l_lnrenfos l_lnglob l_lntrd l_lnefp l_lnurb l_lnylabor
* Model III
xtserial dlnco2pubk dlnrenfos dlnglob dlntrd dlnefp dlnurb dlnylabor l_lnco2totk l_lnrenfos l_lnglob l_lntrd l_lnefp l_lnurb l_lnylabor

* Table A6 Estimated models
* Model I
xtqreg dlnco2totk dlnrenfos dlnglob dlntrd dlnefp dlnurb dlnylabor l_lnco2totk l_lnrenfos l_lnglob l_lntrd l_lnefp l_lnurb l_lnylabor, i(country) quantile(.5) ls
nlcom(ratio1:-_b[l_lnrenfos]/_b[l_lnco2totk])
nlcom(ratio1:-_b[l_lnglob]/_b[l_lnco2totk])
nlcom(ratio1:-_b[l_lntrd]/_b[l_lnco2totk])
nlcom(ratio1:-_b[l_lnefp]/_b[l_lnco2totk])
nlcom(ratio1:-_b[l_lnurb]/_b[l_lnco2totk])
nlcom(ratio1:-_b[l_lnylabor]/_b[l_lnco2totk])
* Model II
xtqreg dlnco2privk dlnrenfos dlnglob dlntrd dlnefp dlnurb dlnylabor l_lnco2privk l_lnrenfos l_lnglob l_lntrd l_lnefp l_lnurb l_lnylabor, i(country) quantile(.5) ls
nlcom(ratio1:-_b[l_lnrenfos]/_b[l_lnco2privk])
nlcom(ratio1:-_b[l_lnglob]/_b[l_lnco2privk])
nlcom(ratio1:-_b[l_lntrd]/_b[l_lnco2privk])
nlcom(ratio1:-_b[l_lnefp]/_b[l_lnco2privk])
nlcom(ratio1:-_b[l_lnurb]/_b[l_lnco2privk])
nlcom(ratio1:-_b[l_lnylabor]/_b[l_lnco2privk])
* Model III
xtqreg dlnco2pubk dlnrenfos dlnglob dlntrd dlnefp dlnurb dlnylabor l_lnco2pubk l_lnrenfos l_lnglob l_lntrd l_lnefp l_lnurb l_lnylabor, i(country) quantile(.5) ls
nlcom(ratio1:-_b[l_lnrenfos]/_b[l_lnco2pubk])
nlcom(ratio1:-_b[l_lnglob]/_b[l_lnco2pubk])
nlcom(ratio1:-_b[l_lntrd]/_b[l_lnco2pubk])
nlcom(ratio1:-_b[l_lnefp]/_b[l_lnco2pubk])
nlcom(ratio1:-_b[l_lnurb]/_b[l_lnco2pubk])
nlcom(ratio1:-_b[l_lnylabor]/_b[l_lnco2pubk])
* FE (D-K) 
* Model I
xtscc dlnco2totk dlnrenfos dlnglob dlntrd dlnefp dlnurb dlnylabor l_lnco2totk l_lnrenfos l_lnglob l_lntrd l_lnefp l_lnurb l_lnylabor,fe
nlcom(ratio1:-_b[l_lnrenfos]/_b[l_lnco2totk])
nlcom(ratio1:-_b[l_lnglob]/_b[l_lnco2totk])
nlcom(ratio1:-_b[l_lntrd]/_b[l_lnco2totk])
nlcom(ratio1:-_b[l_lnefp]/_b[l_lnco2totk])
nlcom(ratio1:-_b[l_lnurb]/_b[l_lnco2totk])
nlcom(ratio1:-_b[l_lnylabor]/_b[l_lnco2totk])
* Model II
xtscc dlnco2privk dlnrenfos dlnglob dlntrd dlnefp dlnurb dlnylabor l_lnco2privk l_lnrenfos l_lnglob l_lntrd l_lnefp l_lnurb l_lnylabor,fe
nlcom(ratio1:-_b[l_lnrenfos]/_b[l_lnco2privk])
nlcom(ratio1:-_b[l_lnglob]/_b[l_lnco2privk])
nlcom(ratio1:-_b[l_lntrd]/_b[l_lnco2privk])
nlcom(ratio1:-_b[l_lnefp]/_b[l_lnco2privk])
nlcom(ratio1:-_b[l_lnurb]/_b[l_lnco2privk])
nlcom(ratio1:-_b[l_lnylabor]/_b[l_lnco2privk])
* Model III
xtscc dlnco2pubk dlnrenfos dlnglob dlntrd dlnefp dlnurb dlnylabor l_lnco2pubk l_lnrenfos l_lnglob l_lntrd l_lnefp l_lnurb l_lnylabor,fe
nlcom(ratio1:-_b[l_lnrenfos]/_b[l_lnco2pubk])
nlcom(ratio1:-_b[l_lnglob]/_b[l_lnco2pubk])
nlcom(ratio1:-_b[l_lntrd]/_b[l_lnco2pubk])
nlcom(ratio1:-_b[l_lnefp]/_b[l_lnco2pubk])
nlcom(ratio1:-_b[l_lnurb]/_b[l_lnco2pubk])
nlcom(ratio1:-_b[l_lnylabor]/_b[l_lnco2pubk])
* FE (robust)
* Model I
xtreg dlnco2totk dlnrenfos dlnglob dlntrd dlnefp dlnurb dlnylabor l_lnco2totk l_lnrenfos l_lnglob l_lntrd l_lnefp l_lnurb l_lnylabor, fe robust
nlcom(ratio1:-_b[l_lnrenfos]/_b[l_lnco2totk])
nlcom(ratio1:-_b[l_lnglob]/_b[l_lnco2totk])
nlcom(ratio1:-_b[l_lntrd]/_b[l_lnco2totk])
nlcom(ratio1:-_b[l_lnefp]/_b[l_lnco2totk])
nlcom(ratio1:-_b[l_lnurb]/_b[l_lnco2totk])
nlcom(ratio1:-_b[l_lnylabor]/_b[l_lnco2totk])
* Model II
xtreg dlnco2privk dlnrenfos dlnglob dlntrd dlnefp dlnurb dlnylabor l_lnco2privk l_lnrenfos l_lnglob l_lntrd l_lnefp l_lnurb l_lnylabor, fe robust
nlcom(ratio1:-_b[l_lnrenfos]/_b[l_lnco2privk])
nlcom(ratio1:-_b[l_lnglob]/_b[l_lnco2privk])
nlcom(ratio1:-_b[l_lntrd]/_b[l_lnco2privk])
nlcom(ratio1:-_b[l_lnefp]/_b[l_lnco2privk])
nlcom(ratio1:-_b[l_lnurb]/_b[l_lnco2privk])
nlcom(ratio1:-_b[l_lnylabor]/_b[l_lnco2privk])
* Model III
xtreg dlnco2pubk dlnrenfos dlnglob dlntrd dlnefp dlnurb dlnylabor l_lnco2pubk l_lnrenfos l_lnglob l_lntrd l_lnefp l_lnurb l_lnylabor, fe robust
nlcom(ratio1:-_b[l_lnrenfos]/_b[l_lnco2pubk])
nlcom(ratio1:-_b[l_lnglob]/_b[l_lnco2pubk])
nlcom(ratio1:-_b[l_lntrd]/_b[l_lnco2pubk])
nlcom(ratio1:-_b[l_lnefp]/_b[l_lnco2pubk])
nlcom(ratio1:-_b[l_lnurb]/_b[l_lnco2pubk])
nlcom(ratio1:-_b[l_lnylabor]/_b[l_lnco2pubk])
